﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using V5_Model;
using V5_BLL;
using V5_Common;

namespace V5_EShop
{
    public class BasicControl : System.Web.UI.UserControl
    {
        public ModelConfig config = null;//全站配置管理
        public ModelChannel channel = null;//频道配置管理
        public ModelUser user = null;
        public BLLUser blluser = new BLLUser();
        public const string AppSettings = "~/Config/KHD.appSettings.config";

        protected override void OnLoad(EventArgs e)
        {
            config = new BLLConfig().GetModel();
            base.OnLoad(e);
        }

        //成功 true 失败false
        protected bool check_member_login()
        {
            if (Request.Cookies["membername"] != null && Request.Cookies["memberid"] != null)
            {
                int userid = Input.SetInt(Request.Cookies["memberid"].Value);
                user = new BLLUser().GetModel(userid);
                return true;
            }
            return false;
        }

        /// <summary>
        /// 获取图片
        /// </summary>
        /// <param name="picsrc"></param>
        /// <param name="pictype"></param>
        /// <returns></returns>
        public string getPic(object picsrc, string pictype)
        {
            string str1 = picsrc.ToString();
            switch (pictype.ToLower())
            {
                case "l":
                    str1 = Helper.Replace(Helper.Replace(str1, "productm", "productl"),
                        "products", "productl");
                    break;
                case "m":
                    str1 = Helper.Replace(Helper.Replace(str1, "productl", "productm"),
                        "products", "productm");
                    break;
                case "s":
                    str1 = Helper.Replace(Helper.Replace(str1, "productl", "products"),
                        "productm", "products");
                    break;
            }
            return str1;
        }
    }
}
